package study.saas.web.portal.sys.admin;


import com.alibaba.dubbo.config.annotation.Reference;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import study.saas.common.util.viewmodel.ApiResultV2;
import study.saas.order.entity.Employee;
import study.saas.order.entity.Porder;
import study.saas.order.service.EmployeeFacade;
import study.saas.order.service.PorderFacade;
import study.saas.order.service.model.PorderAddDTO;
import study.saas.order.service.model.PorderFilterDTO;
import study.saas.order.service.model.PorderModifyDTO;

/**
 * @author wwy
 */
@Api(tags = "订单管理")
@RestController
@RequestMapping(value = "sys/porder")
public class PorderController {

    @Reference(version = "1.0.0")
    private PorderFacade porderFacade;

    @ApiOperation(value = "查询")
    @RequestMapping(value = "/find", method = RequestMethod.GET)
    public ApiResultV2<Porder> findPorder(Integer porderId) {
        if (porderId == null ) {
            return ApiResultV2.error("数据不能为空！");
        }

        return porderFacade.findPorder(porderId);
    }

    @ApiOperation(value = "添加")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public ApiResultV2<Porder> addPorder(PorderAddDTO add){
        if(add ==null){
            return ApiResultV2.error("数据不能为空!");
        }
        return porderFacade.addPorder(add);
    }

    @ApiOperation(value = "删除")
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    public ApiResultV2<Porder> deletePorder(Integer porderId){
        if(porderId ==null){
            return ApiResultV2.error("数据不能为空!");
        }
        return porderFacade.deletePorder(porderId);
    }

    @ApiOperation(value = "修改")
    @RequestMapping(value = "/modify",method = RequestMethod.POST)
    public ApiResultV2<Porder> modifyPorder(PorderModifyDTO modify){
        if(modify ==null){
            return ApiResultV2.error("数据不能为空！");
        }
        return porderFacade.modifyPorder(modify);
    }

    @ApiOperation(value = "/修改")
    @RequestMapping(value = "/list",method= RequestMethod.POST)
    public  ApiResultV2<Porder> listPorder(PorderFilterDTO filter){
        if(filter ==null){
            return ApiResultV2.error("数据不能为空!");
        }
        return porderFacade.listPorder(filter);
    }

}
